<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>打印测试</title>
    <script language="javascript" type="text/javascript">
        function CheckIsInstall() {
            try {
                //var LODOP = getLodop();
                var LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
                if (LODOP.VERSION) {
                    if (LODOP.CVERSION)
                        alert("当前有C-Lodop云打印可用!\n C-Lodop版本:" + LODOP.CVERSION + "(内含Lodop" + LODOP.VERSION + ")");
                    else
                        alert("本机已成功安装了Lodop控件！\n 版本号:" + LODOP.VERSION);

                }
                ;
            } catch (err) {
            	console.log(err);
            }
        }
        ;
        function print3(){
        	var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement;
            console.info(head);

            // 让其它电脑的浏览器通过本机打印（仅适用C-Lodop自带的例子）：
            var oscript = document.createElement('script');
            // oscript.src ="/CLodopfuncs.js";
            // head.insertBefore( oscript,head.firstChild );
            // 让本机的浏览器打印(更优先一点)：
            oscript = document.createElement('script');
            oscript.src = 'http://localhost:8000/CLodopfuncs.js?priority=2';
            head.insertBefore(oscript, head.firstChild);

            // 加载双端口(8000和18000）避免其中某个端口被占用：
            oscript = document.createElement('script');
            oscript.src = 'http://localhost:18000/CLodopfuncs.js?priority=1';
            head.insertBefore(oscript, head.firstChild);
        	
        	
        	
        	
        	window.setTimeout(function(){
        		var LODOP = getCLodop();
            	//LODOP.ADD_PRINT_HTM("10%",0, "100%","80%","URL:http://www.baidu.com"); 
            	LODOP.PRINT_INIT("打印测试1");               //首先一个初始化语句 
            	var pContent=[];
            	pContent.push("<div style='color:red; font-size:12px; height:20px; line-height:20px;'>文本内容一打印</div>");
            	pContent.push("<div style='background-color: pink; font-size:12px; height:20px; line-height:20px;'>超大卖鸡店</div>");
            	pContent.push("<div style='height:30px; line-height:30px;'>&nbsp;</div>");
            	pContent.push("<div style='font-size:12px; height:20px; line-height:20px;'>金龙鱼</div>");
            	pContent.push("<div style='font-size:12px; height:20px; line-height:20px;'>36桶</div>");
            	//pContent.push("<div style='font-size:12px; height:20px; line-height:20px;'>打印时间: 20110101</div>");
            	LODOP.ADD_PRINT_HTM(0,5,300,200,pContent.join(''));//然后多个ADD语句及SET语句 
            	LODOP.ADD_PRINT_BARCODE(45,10,100,20,"128A","123456789012");
            	LODOP.SET_PRINT_STYLEA(0,"ShowBarText",0);
            	LODOP.SET_PRINT_PAGESIZE(1,400,400,"");
            	LODOP.PREVIEW();                               //最后一个打印(或预览、维护、设计)语句PREVIEW
        	}, 1000);
        	
        }
    </script>
</head>
<body>
<a href="javascript:CheckIsInstall()">test</a>

<button onclick="print3()">打印标签</button>
</body>
</html>